package com.team.game.Game.MapHelper;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.MotionEvent;

import com.team.game.Screens.Setting_Screen;
import com.team.game.framework.Game;
import com.team.game.framework.impl.MainActivity;

import java.io.IOException;
import java.io.InputStream;

import static com.team.game.framework.impl.Scale_X_Y.Scale_X;
import static com.team.game.framework.impl.Scale_X_Y.Scale_Y;


public class Location {

    Game game;

    public Border border;

    private int i = 0;
    private int down = 0;

    public Location (Game game){
        this.game = game;
        border = new Border(game, 1);

    }

    public void present(Canvas canvas){
        border.present (canvas);
    }

    public void update (){
        border.update ();
    }

    public boolean animate(){
        if (i < 20) {
            i++;
            border.update();
            return false;
        } else {
            i = 0 ;
            return true;
        }
    }

    public boolean unroll () {
        if (i < 20) {
            i++;
            border.update();
            return false;
        } else {
            i = 0;
            return true;
        }
    }

    public boolean OnScroll (MotionEvent event) {
        switch (event.getAction ()) {
            case MotionEvent.ACTION_DOWN: {
                down = border.touch(event);
                if(down == 0)
                {

                }
                break;
            }
            case MotionEvent.ACTION_UP: {
                if (down == 0)
                {
                    //return true;
                }
                else {
                    if(down == border.touch(event))
                    {
                        if (down == 1)
                            return true;
                        else
                            setReguestedScreen (down);
                    }
                }
                break;
            }
        }

        return false;
    }

    public void setReguestedScreen (int a){
        switch (a){
            case 1:
                break;
            case 2:
                game.setScreen (new Setting_Screen (game));
                break;
            case 3:
                break;
            case 4:
                break;
        }
    }

    public void test () {
        InputStream inputStream;
        try {
            inputStream = MainActivity.manager.open ("Picture/fullmap.jpg");
            Bitmap fullmap = Bitmap.createScaledBitmap (BitmapFactory.decodeStream (inputStream), (int) (3240 * Scale_X), (int) (3840 * Scale_Y), false);
        } catch (IOException e) {
            e.printStackTrace ();
        }
    }

}
